
// 使用 myevent 里面和外面的 list 都行
 const myEvent = {
  list:{},
  listen:function(key,fn){

    if(!this.list[key]) {
      this.list[key] = [];
    }
    this.list[key].push(fn);

    
  },
  trigger:function(){
    
      var key = Array.prototype.shift.call(arguments),
          fns = this.list[key];
         
      if(!fns || fns.length === 0) {
          return false;
      }
      console.log(333,fns)
      for(var i = 0, fn; fn = fns[i++];) {
          fn.apply(this,arguments);
      }
  },
  remove: function(key,fn){
    console.log(this)
      var fns = this.list[key];
      if(!fns) {
          return false;
      }
      if(!fn) {
          fns && (fns.length = 0);
      }else {
          for(var i = fns.length - 1; i >= 0; i--){
              var _fn = fns[i];
              if(_fn === fn) {
                  fns.splice(i,1);
              }
          }
      }
  }
  
}

export default myEvent